﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;
using ApplicationLayer;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace Blokus.Scenes
{
    class SceneEditGame : Scene
    {
        private KeyboardState keyPrevState;
        private GamePadState gpPrevState;

        private Texture2D px;
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        private SpriteFont menuFont;

        public override void LoadContent(ContentManager content, GraphicsDeviceManager graphics)
        {
            this.graphics = graphics;
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(graphics.GraphicsDevice);
            px = content.Load<Texture2D>("pxTan");
            menuFont = content.Load<SpriteFont>("GameText");
        }

        public override Blokus.GameState Update(GameTime gameTime)
        {
            return Blokus.GameState.DESIGNER_EDIT;
        }

        public override void Draw(GameTime gameTime)
        {
            List<string> games = new List<string>();
            games.Add("Default");
            games.Add("Blokus++");
            games.Add("Blokus#");
            int buffer = 50;
            int gameStartY = 112;
            graphics.GraphicsDevice.Clear(colorMiddle);
            spriteBatch.Begin();
            int xOffset = 120;
            Rectangle border = new Rectangle(xOffset, 70, 250, gameStartY);
            spriteBatch.Draw(px, new Rectangle(border.Left + 10, 112, border.Right - border.Left - 20, (int)menuFont.MeasureString("Default").Y), colorLight); //Highlight
            foreach (string s in games)
            {
                spriteBatch.DrawString(menuFont, s, new Vector2(xOffset + 20, gameStartY), Color.Black);
                gameStartY += buffer;
            }
            border = new Rectangle(xOffset, 70, 250, gameStartY);
            FreqUsed.DrawSquare(border, 10, colorDark, spriteBatch, px);
            FreqUsed.DrawSquareWithFill(new Rectangle(xOffset + 12, 57, 150, 40), 2, colorLight, Color.White, spriteBatch, px);
            spriteBatch.DrawString(menuFont, "Games", new Vector2(xOffset + 20, 62), Color.Black);
            spriteBatch.End();
        }

        public override void ResetPrevKeys()
        {
            keyPrevState = Keyboard.GetState();
            gpPrevState = GamePad.GetState(PlayerIndex.One);
        }
    }
}
